package cn.hnucm.searchesservice.service.impl;

import cn.hnucm.searchesservice.dao.TbGoodsBasisDao;
import cn.hnucm.searchesservice.entity.TbGoodsBasis;
import cn.hnucm.searchesservice.service.TbGoodsBasisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author chenjintao
 * @since 2021-12-20
 */
@Service
public class TbGoodsBasisServiceImpl implements TbGoodsBasisService {

    @Autowired
    @Qualifier("tbGoodsBasisDaoImpl")
    private TbGoodsBasisDao dao;

    /**
     * 获取所有的商品信息
     * @return
     */
    @Override
    public List<TbGoodsBasis> getAllGoods() {
        return dao.getAllGoods();
    }

    /**
     * 根据商品号查询商品信息
     * @param goodsId
     * @return
     */
    @Override
    public TbGoodsBasis getGoodsById(Integer goodsId) {
        return dao.getGoodsById(goodsId);
    }

    /**
     * 根据商品名称和商品简介模糊查询
     * @param describe
     * @return
     */
    @Override
    public List<TbGoodsBasis> getGoodsByDescribe(String describe) {
        return dao.getGoodsByDescribe(describe);
    }

    /**
     * 根据商品分类查询
     * @param goodsType
     * @return
     */
    @Override
    public List<TbGoodsBasis> getGoodsByType(String goodsType) {
        return dao.getGoodsByType(goodsType);
    }

    /**
     * 根据卖家查询
     * @param goodsOwerId
     * @return
     */
    @Override
    public List<TbGoodsBasis> getGoodsBySend(Integer goodsOwerId) {
        return dao.getGoodsBySend(goodsOwerId);
    }

    /**
     * 根据价格区间查询
     * @param highPrice
     * @param lowPrice
     * @return
     */
    @Override
    public List<TbGoodsBasis> getGoodsByPrice(Double highPrice, Double lowPrice) {
        return dao.getGoodsByPrice(highPrice,lowPrice);
    }

    /**
     * 添加一条商品信息记录
     * @param tbGoodsBasis
     * @return
     */
    @Override
    public Boolean addGoods(TbGoodsBasis tbGoodsBasis) {
        return dao.addGoods(tbGoodsBasis);
    }

    /**
     * 通过商品Id删除一条商品记录
     * @param goodsId
     * @return
     */
    @Override
    public Boolean deleteGoodsById(Integer goodsId) {
        return dao.deleteGoodsById(goodsId);
    }

    /**
     * 通过商品Id修改商品信息,其id和修改后的信息一同封装在 TbGoodsBasis中
     * @param tbGoodsBasis
     * @return
     */
    @Override
    public Boolean updateGoodsById(TbGoodsBasis tbGoodsBasis) {
        return dao.updateGoodsById(tbGoodsBasis);
    }

}
